package gui;
/**
 * ImagePanel creates the framework for a JPanel that has an image as a
 * background
 */
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class ImagePanel extends JPanel {
	
	  private Image img;
	  
	  /**
	   * Constructor for the ImagePanel class that takes a string representation
	   * of the background image
	   * @param img Input string which holds image
	   */
	  public ImagePanel(String img) {
	    this(new ImageIcon(img).getImage());
	  }

	  /**
	   * Constructor for the ImagePanel class that takes a background image and
	   * creates the appropriate JPanel from it
	   * @param img Input image
	   */
	  public ImagePanel(Image img) {
	    this.img = img;
	    Dimension size = new Dimension(img.getWidth(null), img.getHeight(null));
	    setPreferredSize(size);
	    setMinimumSize(size);
	    setMaximumSize(size);
	    setSize(size);
	    setLayout(null);
	  }

	  /**
	   * Applies image to JPanel
	   */
	  public void paintComponent(Graphics g) {
	    g.drawImage(img, 0, 0, null);
	  }
}